package de.lulusoft.anothertorrent.gui.views.Providers;

import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.swt.graphics.Image;

import de.lulusoft.anothertorrent.core.rtorrent.Peer;
import de.lulusoft.anothertorrent.gui.util.Util;

public class PeersTableLabelProvider implements ITableLabelProvider {

	@Override
	public Image getColumnImage(Object element, int columnIndex) {
		return null;
	}

	@Override
	public String getColumnText(Object element, int columnIndex) {
		if (element instanceof Peer)
		{
			Peer f = (Peer)element;
			switch (columnIndex)
			{
			case 0: return f.getAddress();
			case 1: return f.getClient_version();
			case 2: return f.getCompleted_percent().toString() + " %";
			case 3: return Util.formatBytes(f.getDown_rate());
			case 4: return Util.formatBytes(f.getUp_rate());
			case 5: return Util.formatBytes(f.getPeer_rate());

			default: return "Not yet implemented";
			}
		}
		return "";
	}

	@Override
	public void addListener(ILabelProviderListener listener) {
	}

	@Override
	public void dispose() {
	}

	@Override
	public boolean isLabelProperty(Object element, String property) {
		return false;
	}

	@Override
	public void removeListener(ILabelProviderListener listener) {
	}

}
